SELECT B.{0}, A.YR, A.MN{1}
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='IN' THEN 1 ELSE	0 END	) IPTV_IN,  
SUM(CASE	WHEN PRODUCT='IPTV' 	AND	DIRECTION='OUT' THEN 1 ELSE	0 END	) IPTV_OUT,  
IPTV_IN-IPTV_OUT IPTV_NET,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='IN' THEN 1 ELSE	0 END	) HSIA_IN,  
SUM(CASE	WHEN PRODUCT='HSIA' 	AND	DIRECTION='OUT' THEN 1 ELSE	0 END	) HSIA_OUT,  
HSIA_IN-HSIA_OUT HSIA_NET,  
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='IN' THEN 1 ELSE	0 END	) VOIP_IN, 
SUM(CASE	WHEN PRODUCT='VOIP' 	AND	DIRECTION='OUT' THEN 1 ELSE	0 END	) VOIP_OUT,  
VOIP_IN-VOIP_OUT VOIP_NET 
FROM	
	MIS.ACC_CAL2 A 
	LEFT OUTER JOIN 
		(  SELECT	B.PRODUCT, B.DIRECTION, B.START_DT, C.{0}
			FROM	MIS.ACC_RAW B  
			INNER JOIN 
					MIS.ACC_BASE_DATA C 
					ON	C.TRAC_ID=B.TRAC_ID 
					AND	 B.TRAC_ID IN 
						(	SELECT	TRAC_ID 
							FROM	MIS.ACC_TRAC_INFO 
							WHERE	{0} IN 
							(SELECT DISTINCT {0}  FROM MIS.ACC_BASE_DATA)
						)   
		) B 
	ON	A.DT=B.START_DT 
GROUP	BY 1,2 ,3
ORDER	BY 1,2,3